package com.woniuxy.mytank.effect;

import java.awt.Graphics;

import javax.swing.JPanel;

import com.woniuxy.mytank.datacenter.DataCenter;
import com.woniuxy.mytank.util.ReadImage;

public class EndGame implements Runnable{
	
	int step=0;
	int time;
	
	public EndGame(int time){
		this.time=time;
		new Thread(this).start();
	}
	
	public void drawEndGame(Graphics g, JPanel p){
		if(!(DataCenter.MMove)){
				g.drawImage(ReadImage.endGame[step], 0, 0, 816, 816, 0, 0, 816, 816, p);
		}
	}

	@Override
	public void run() {
		while(true){
			try {
				Thread.sleep(100);
				time--;
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			step++;
			if(step>30){
				step=30;
			}
			if(time<0){
				break;
			}
			/*if(time<0){
				break;
			}*/
		}
	}

}
